Main Index
Gravitational N-Body Simulation

Software

Acknowledgments and Future updates

Errors, bugs and problems

Running a simulation

Saving and Loading parameter files

Technical Details

Technical details


Saving and Loading

This version of the software allows you to save the initial configuration of a simulation. The parameters in the Setup dialogue box along with the initial positions and velocities of the initial particle configuration are saved when the chosen file is saved using the Save or SaveAs menu commands. The settings of all the comboboxes are also saved. The file is saved in a simple text format.

An existing .nbd data file can be loaded using either the Load or Load and Run menu commands. The initial positions of the particles are scaled to appear similar to they were when the data was originally saved, relative to the window size.

This version loads and saves .nbd files in v1.7 format (i.e., the version before this one that did not have the rotating frame option).


Running a Simulation

To run a simulation, you can load a previously saved initial parameter set, or you can start by clicking on the window where you want to place the particle:

Choose the current bitmap you wish to use from the first combobox on the toolbar. There are 13 different bitmaps to choose from.

Choose the current mass you wish to use from the second combobox. The masses are in units of the male scale factor (set in the Setup dialogue box), with each successive mass being a factor 10 times heavier than the preceding one.

Choose the data entry mode from the third combobox. In the Standard mode, you may:

•	lick with the left mouse button on the point where you wish to place a particle with zero initial kinetic energy (zero velocity), OR:

C

•	Click and hold the right mouse button to place a particle at the starting point. Move the mouse cursor (which drags a line) to another point and release the right mouse button. The line represents the initial velocity vector of the particle, with the length of the line being proportional to the magnitude of the initial velocity. The actual magnitude is determined by the value of the velocity scale factor in the Setup dialogue box.

The other data entry modes automatically calculate the initial velocity vector of the body:

•	By using the Circle mode, you can place a body in a circular orbit about any other body you choose. To do this, first click on the spot you would like to place the orbiting body, then click on the center body. The program will automatically calculate the correct initial velocity of the body, assuming that the interactions due to other bodies are minimal. Using the left mouse button results in a clockwise orbit. Use the right mouse button for an anticlockwise orbit.

•	The Circles mode is similar, except that you first click on the center body, after which all subsequent bodies will be placed in circular orbits, until the data entry mode is changed again.

After you have produced as many particles as you like, choose the run option in the Simulation menu to start the simulation. At any time, you may pause the simulation thread, or increase its priority. Clicking with the right mouse button during the simulation centers the screen at the mouse cursor.

You may choose a Fixed Origin (default), the Center of Mass coordinate system, or use any one of the bodies as a Moving Frame. When you use the Moving Frame option, clicking the left mouse button will center the screen on the closest body to the mouse cursor. The Rotating Frame option works similarly, with the origin of the frame at the center of mass, and the frame rotates with the same angular velocity as the selected body.

There is a reverse option in the Simulation menu which reverses the velocities of the particles. If there are close encounters between bodies, the reverse option will not be as accurate, due to the approximations performed in this calculation.

It is also possible to speed up or slow down the simulation by a factor of 2.5 or 10, or to zoom out or in, by factors of 2.5, 10 or 100.

To end the simulation, use the end command in the simulation menu. To start another simulation, use the new command.


Future Updates
Acknowledgments and Future Updates

This version of the software is version 1.80.95 (April 1995).

This is the fourth version of the software that I have released as Freeware software. I have received a few comments and suggestions about the first version (1.0 alpha). This version contains a few bugs.

Most of the good ideas originally came from my advisor, Tom Walsh. The original algorithm was written by Sverre Aarseth, although he would probably want to distance himself from this crude implementation.

Many thanks to John Tauxe and Maurice Tardif for very helpful comments and suggestions about the first version.

If you have any comments or suggestions, I would enjoy hearing from you (and you would be the first to get a new version). My email address is:

hquadling@mnhep.hep.umn.edu

This application is available for the following platforms:

•	Windows 95 and Windows NT (x86)

•	Windows NT (Alpha AXP)

There is a very much simplified and crude 16 bit DOS version available at the SIMTEL site.


Technical Details

This program uses the algorithm by Sverre Aarseth described in the book Multiple Time Scales. The calculation is a true 3D calculation (although only two dimensions are displayed in this version), and all interactions between all particles are taken into account.

The actual algorithm used is a very crude one that only works reasonably well with relatively large softening parameters. I will be improving the algorithm, or provide additional improved algorithms as an option.

The numerical calculations are carried out on a separate low priority thread, which is never idle while a simulation is running, i.e., timer messages are not used. The calculation thread also draws the particles on the window which is controlled by the parent thread. Advantages of this approach include smooth multitasking, and a high efficiency for the numerical calculations, especially for large simulations. Disadvantages include irritating flashing of the larger bitmaps in the small simulations. This program has really been optimized for use with many particles. The graphics will be improved in a later version, by using the more advanced graphics capabilities of NT3.5.


Problems
Errors, bugs and problems

This software is certainly not perfect. Here are a few of the many problems which I have seen:

•	Sometimes the particles suddenly jump or change their momentum in a way which is not physically possible. This is rare, and may be due to a softening parameter which is too large (this algorithm is very crude..)

•	Very close encounters can slow the algorithm down or produce incorrect results. This is due to the highly singular 1/r^2 potential, and incorrect use of the eta parameter, I suppose.

•	If nothing seems to be happening, in spite of resuming the simulation, try increasing the simulation priority. This sometimes happens if you have Win16 applications (or other applications which demand constant attention from the CPU) running.

•	There are problems with window repaints, in some circumstances. In these cases, just do something (such as changing a display mode) that you know will repaint the window.

•	You cannot save a simulation with the Rotating Frame option. This is to avoid a more serious, ahem, bug.

•	Sometimes when you create a new system, and then resize the window before saving (or something similar to this), you will notice something wrong when you load the nbd data file the next time. To avoid this serious bug, make sure you dont resize the window when you are creating new data files.

The next version is likely to be a vast improvement over this one, so look out for it!